import java.util.Calendar;
import java.util.Date;


public class DateCompare {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// Create first calendar
		Calendar c1 = Calendar.getInstance();
		
		// now delay so there is a time difference
		for (long i=0; i < 100000; i++) { for(long j=0; j < 100000; j++) {} }
		
		// Create second calendar
		Calendar c2 = Calendar.getInstance();
		
		// Check they are different
		System.out.println("Different:");
		System.out.println("c1 time="+c1.getTime());
		System.out.println("c2 time="+c2.getTime());
		System.out.println("c1 compared to c2:" + c1.compareTo(c2));

		setToMidnight(c1);
		setToMidnight(c2);
		
		// Check they are Same
		System.out.println("Same:");
		System.out.println("c1 time="+c1.getTime());
		System.out.println("c2 time="+c2.getTime());
		System.out.println("c1 compared to c2:" + c1.compareTo(c2));
	
		
	}

	public static void setToMidnight(Calendar calendar) {
		calendar.set(Calendar.MILLISECOND, 0);
		calendar.set(Calendar.HOUR, 0);
		calendar.set(Calendar.MINUTE, 0);
		calendar.set(Calendar.SECOND, 0);
	}
}